<!-- Le javascript
    ================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="__TMPL__/public/assets/echehui/bootstrap/js/bootstrap.min.js"></script>
<script src="__STATIC__/js/frontend.js"></script>
<script>
    $(function() {
        $("#main-menu li.dropdown").hover(function() {
            $(this).addClass("open");
        }, function() {
            $(this).removeClass("open");
        });

        $("#main-menu a").each(function() {
            if ($(this)[0].href == String(window.location)) {
                $(this).parentsUntil("#main-menu>ul>li").addClass("active");
            }
        });
        (function($) {
            $.fn.totop = function(opt) {
                var scrolling = false;
                return this.each(function() {
                    var $this = $(this);
                    $(window).scroll(function() {
                        if (!scrolling) {
                            var sd = $(window).scrollTop();
                            if (sd > 100) {
                                $this.fadeIn();
                            } else {
                                $this.fadeOut();
                            }
                        }
                    });

                    $this.click(function() {
                        scrolling = true;
                        $('html, body').animate({
                            scrollTop: 0
                        }, 500, function() {
                            scrolling = false;
                            $this.fadeOut();
                        });
                    });
                });
            };
        })(jQuery);

        $("#backtotop").totop();


        $("ul#main-menu").find('li').removeClass("change");
        $("ul#main-menu").find('.active').prev('li').addClass("change");

    });
</script>